﻿namespace HuaWei.Windows.Forms
{
    using HuaWei;
    using HuaWei.BusinessRule;
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.IO;
    using System.Windows.Forms;

    public class FrmLogin_Back : Form
    {
        private string _str;
        private Button btnCancel;
        private Button btnLinkTest;
        private Button btnOK;
        private CBaseRule cbaseRule;
        private ComboBox cbServerAddr;
        private Label label1;
        private Label label3;
        private Label label4;
        private Label label5;
        private Panel panel1;
        private PictureBox pictureBox1;
        private TextBox txtLoginName;
        private TextBox txtPassword;

        public FrmLogin_Back()
        {
            this.InitializeComponent();
            this._str = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "System.ini");
            this.cbaseRule = new CBaseRule();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            base.DialogResult = System.Windows.Forms.DialogResult.Cancel;
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            base.DialogResult = System.Windows.Forms.DialogResult.OK;
        }

        private void InitializeComponent()
        {
            ComponentResourceManager resources = new ComponentResourceManager(typeof(FrmLogin_Back));
            this.pictureBox1 = new PictureBox();
            this.btnCancel = new Button();
            this.btnOK = new Button();
            this.label1 = new Label();
            this.btnLinkTest = new Button();
            this.cbServerAddr = new ComboBox();
            this.panel1 = new Panel();
            this.label5 = new Label();
            this.txtPassword = new TextBox();
            this.txtLoginName = new TextBox();
            this.label4 = new Label();
            this.label3 = new Label();
            ((ISupportInitialize) this.pictureBox1).BeginInit();
            this.panel1.SuspendLayout();
            base.SuspendLayout();
            this.pictureBox1.Dock = DockStyle.Top;
            this.pictureBox1.Image = (Image) resources.GetObject("pictureBox1.Image");
            this.pictureBox1.Location = new Point(0, 0);
            this.pictureBox1.Name = "pictureBox1";
            this.pictureBox1.Size = new Size(0x197, 0x48);
            this.pictureBox1.TabIndex = 12;
            this.pictureBox1.TabStop = false;
            this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.btnCancel.Location = new Point(0x12d, 12);
            this.btnCancel.Name = "btnCancel";
            this.btnCancel.Size = new Size(0x4b, 0x17);
            this.btnCancel.TabIndex = 1;
            this.btnCancel.Text = "取消";
            this.btnCancel.UseVisualStyleBackColor = true;
            this.btnCancel.Click += new EventHandler(this.btnCancel_Click);
            this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK;
            this.btnOK.Location = new Point(220, 12);
            this.btnOK.Name = "btnOK";
            this.btnOK.Size = new Size(0x4b, 0x17);
            this.btnOK.TabIndex = 0;
            this.btnOK.Text = "确定(&O)";
            this.btnOK.UseVisualStyleBackColor = true;
            this.btnOK.Click += new EventHandler(this.btnOK_Click);
            this.label1.AutoSize = true;
            this.label1.Location = new Point(0x43, 0x68);
            this.label1.Name = "label1";
            this.label1.Size = new Size(0x41, 12);
            this.label1.TabIndex = 14;
            this.label1.Text = "服务器地址";
            this.btnLinkTest.Location = new Point(0x1b, 12);
            this.btnLinkTest.Name = "btnLinkTest";
            this.btnLinkTest.Size = new Size(0x4b, 0x17);
            this.btnLinkTest.TabIndex = 2;
            this.btnLinkTest.Text = "链接测试";
            this.btnLinkTest.UseVisualStyleBackColor = true;
            this.cbServerAddr.FormattingEnabled = true;
            this.cbServerAddr.Location = new Point(0x88, 0x62);
            this.cbServerAddr.Name = "cbServerAddr";
            this.cbServerAddr.Size = new Size(0xc6, 20);
            this.cbServerAddr.TabIndex = 13;
            this.panel1.Controls.Add(this.label5);
            this.panel1.Controls.Add(this.btnCancel);
            this.panel1.Controls.Add(this.btnOK);
            this.panel1.Controls.Add(this.btnLinkTest);
            this.panel1.Dock = DockStyle.Bottom;
            this.panel1.Location = new Point(0, 0xb9);
            this.panel1.Name = "panel1";
            this.panel1.Size = new Size(0x197, 0x30);
            this.panel1.TabIndex = 0x15;
            this.label5.BorderStyle = BorderStyle.Fixed3D;
            this.label5.Dock = DockStyle.Top;
            this.label5.Location = new Point(0, 0);
            this.label5.Name = "label5";
            this.label5.Size = new Size(0x197, 2);
            this.label5.TabIndex = 11;
            this.txtPassword.Location = new Point(0x88, 0x98);
            this.txtPassword.Name = "txtPassword";
            this.txtPassword.PasswordChar = '*';
            this.txtPassword.Size = new Size(0xc6, 0x15);
            this.txtPassword.TabIndex = 0x12;
            this.txtLoginName.Location = new Point(0x88, 0x7d);
            this.txtLoginName.Name = "txtLoginName";
            this.txtLoginName.Size = new Size(0xc6, 0x15);
            this.txtLoginName.TabIndex = 0x11;
            this.label4.AutoSize = true;
            this.label4.Location = new Point(0x43, 0x9e);
            this.label4.Name = "label4";
            this.label4.Size = new Size(0x1d, 12);
            this.label4.TabIndex = 20;
            this.label4.Text = "密码";
            this.label3.AutoSize = true;
            this.label3.Location = new Point(0x43, 0x83);
            this.label3.Name = "label3";
            this.label3.Size = new Size(0x29, 12);
            this.label3.TabIndex = 0x13;
            this.label3.Text = "用户名";
            base.ClientSize = new Size(0x197, 0xe9);
            base.Controls.Add(this.label1);
            base.Controls.Add(this.cbServerAddr);
            base.Controls.Add(this.panel1);
            base.Controls.Add(this.txtPassword);
            base.Controls.Add(this.txtLoginName);
            base.Controls.Add(this.label4);
            base.Controls.Add(this.label3);
            base.Controls.Add(this.pictureBox1);
            base.Name = "FrmLogin";
            base.StartPosition = FormStartPosition.CenterScreen;
            ((ISupportInitialize) this.pictureBox1).EndInit();
            this.panel1.ResumeLayout(false);
            base.ResumeLayout(false);
            base.PerformLayout();
        }

        private void method()
        {
            try
            {
                string filename = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "System.ini");
                string str2 = IniFile.ReadIniFile(filename, "DB", "connstr", false);
                IniFile.ReadIniFile(filename, "DB", "DBType", false);
                int index = str2.IndexOf("=");
                int num2 = str2.IndexOf(";");
                string str3 = str2.Substring(index + 1, (num2 - index) - 1);
                str2 = str2.Substring(num2 + 1, (str2.Length - num2) - 1);
                index = str2.IndexOf("=");
                num2 = str2.IndexOf(";");
                str2.Substring(index + 1, (num2 - index) - 1);
                str2 = str2.Substring(num2 + 1, (str2.Length - num2) - 1);
                index = str2.IndexOf(";");
                str2 = str2.Substring(index + 1, (str2.Length - index) - 1);
                index = str2.IndexOf("=");
                num2 = str2.IndexOf(";");
                string str4 = str2.Substring(index + 1, (num2 - index) - 1);
                str2 = str2.Substring(num2 + 1, (str2.Length - num2) - 1);
                index = str2.IndexOf("=");
                string str5 = str2.Substring(index + 1, (str2.Length - index) - 1);
                this.cbServerAddr.Text = str3;
                this.txtLoginName.Text = str4;
                this.txtPassword.Text = str5;
            }
            catch (Exception exception)
            {
                MsgBox.ShowMsg(exception.ToString());
            }
        }

        private void method1()
        {
            try
            {
                string filename = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "System.ini");
                string keyValue = string.Format("Data Source={0};Initial Catalog={1};Persist Security Info=True;User ID={2};Password={3}", this.cbServerAddr.Text, this.txtLoginName.Text, this.txtPassword.Text);
                IniFile.WriteIniFile(filename, "DB", "connStr", keyValue, false);
            }
            catch (Exception exception)
            {
                MsgBox.ShowError(exception);
            }
        }

        private void method2(string _str1)
        {
            try
            {
                IniFile.WriteIniFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "System.ini"), "DB", "ServerDBType", _str1, false);
            }
            catch (Exception exception)
            {
                MsgBox.ShowMsg(exception.ToString());
            }
        }

        private void method3(object sender, EventArgs e)
        {
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
        }
    }
}

